/**
 * 
 */
package org.keum.android.lecture;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

/**
 * @author Alan
 *
 */
public class LinearLayoutDemo extends Activity implements OnCheckedChangeListener {
	
	RadioGroup orientation;
	RadioGroup gravity;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.linearlayoutdemo);
		
		orientation = (RadioGroup)findViewById(R.id.orientation);
		orientation.setOnCheckedChangeListener(this);
		gravity = (RadioGroup)findViewById(R.id.gravity);
		gravity.setOnCheckedChangeListener(this);
	}

	public void onCheckedChanged(RadioGroup group, int checkedId) {
		// TODO Auto-generated method stub
		if(group==orientation){
			if(checkedId==R.id.horizontal){
				orientation.setOrientation(LinearLayout.HORIZONTAL);
			}
			else if(checkedId==R.id.vertical){
				orientation.setOrientation(LinearLayout.VERTICAL);
			}
		}
		else if(group==gravity){
			switch(checkedId){
				case R.id.left:
					gravity.setGravity(Gravity.LEFT);
					break;
				case R.id.center:
					gravity.setGravity(Gravity.CENTER);
					break;
				case R.id.right:
					gravity.setGravity(Gravity.RIGHT);
					break;
			}
		}
	}

}
